#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //设置窗口的默认尺寸
    this->setGeometry(0, 0, 500, 500);

    //设置进度条的范围
    ui->horizontalSlider->setRange(100, 1000);
    ui->verticalSlider->setRange(100, 1000);
    //设置进度条的当前值
    ui->horizontalSlider->setValue(500);
    ui->verticalSlider->setValue(500);
    //设置方向键每次调整的大小
    ui->horizontalSlider->setSingleStep(50);
    ui->verticalSlider->setSingleStep(50);
}

Widget::~Widget()
{
    delete ui;
}

//修改宽度
void Widget::on_horizontalSlider_valueChanged(int value)
{
    QRect rect = this->geometry();
    this->setGeometry(rect.x(), rect.y(), value, rect.width());
}


void Widget::on_verticalSlider_valueChanged(int value)
{
    QRect rect = this->geometry();
    this->setGeometry(rect.x(), rect.y(), rect.width(), value);
}
